User blog:Cheatfreak47/Some Technical Documentation on The Sims 2 for DS
Afternoon everyone. I'm CheatFreak. I grew up playing The Sims 2 (DS) and I decided one day recently out of the blue to make Action Replay codes for it. In doing so, I developed a lot of skills, and took a lot of notes, particularly about''' how the game works internally.' All of this work was done with the '''USA version of the game' in the DeSmuMe Emulator, meaning all relevant addresses mentioned and discussed will be for that specific version of the game. However, region converting the codes isn't that hard and I've already done it for all of the codes I made, and those will be published on the Action Replay codes page sooner or later when I get around to formatting it correctly. This blog post is rather technical in nature and it assumes you have at least enough grasp of computers to understand things at least some fundamentals about things like Binary, Hexadecimal, Bits, Bytes, Pointers, Endianness, etc. One more note: When using the latest nightly DeSmuMe, Sims 2 works best with a JIT blocksize of 15. Any higher will cause the game to run into many visual glitches with menus. Older versions, the game had issues at anything higher than 12. If you have questions about anything I'm publishing here, I'd be happy to answer questions. In addition, I can be contacted on Discord very easily if you'd like to chat. My Discord username is CheatFreak#3799. Please contact me of any of the links on this page go down, such as the various Pastebin ones. This documentation is far from complete and it's really just a bunch of notes for anyone interested in poking around in the game. I may even edit my blog post in the future with more info if I feel like messing with this game again. I'd like to shout out three friends of mine who are partly responsible for my work on this game. These people are Shilz, for his interest in the game and my work on it, yoyoyoshio, who is a friend of mine that had some good ideas for codes, and DeadSkullzJr, a friend of mine who maintains the best DS AR Cheat Database on the internet - I've shared my codes with him and they are now included in his cheat database. Without further delay, let's get into it. This blog is going to lack a distinct structure beyond being a huge info dump, but I'll try my best to make it easy to digest. Cellphone Mechanics I didn't get super far into figuring out how this works but based on a lead from Shilz about how the game decides to ring your phone, I determined that the phone rings for random calls at the tick of the in-game minute counter. Here are some relevant addresses to the phone in the USA version. Is Phone Ringing Or Not (1 or 0, 1-byte value) 216A122 Person Calling 216A120 Message to Display 216A11C Clock: Minute 216B768 I made a code later for Action Replay codes that allows you to Press and Hold Select to induce these phone calls, along with any other events that happen at minutes tick. Keelhaulin' Cards While pointless, I was slightly curious about it so I decided to look into it anyway. This was the first thing I worked with that dealt with pointers in the game. Keelhaulin' Pointer 2139110 This address points to the area of ram where data for Keelhaulin' games will be stored. Here are some useful offsets for the target location: Player Points: 2CC Opponent Points: 2D0 The game ends when one of the above offsets is filled with Hex C8 (or 200 in decimal). The value for the treasure chest is also somewhere nearby these other two offsets but I forgot to document it. Useful Keelhaulin' Graphics Byte 213D454 In addition, I also located an address to determine easily if the graphics for Keelhaulin' are loaded. This ensures that any code I use the pointer and offsets for only applies when Keelhaulin' is actually open, which makes the code stable. It's 1 when open, 0 when not. Room Loading While I was on my quest to figure out why Honest Jackson was disappearing after Ava Cadavra arrived, I decided it'd be useful to figure out how the game decides what room to load you into next. It was very easy to manipulate. Next Room to Load: 219CAF8 Current Location: 216B494 If you manually set the first address above to be one of the values listed in the room list below while moving from one room to another, it will warp you to the target location instead. This doesn't really fit anywhere else but I have this address as well, used for the Honest Jackson bugfix. It controls the current occupant of the penthouse and what mission strand you are on. Antagonist Flag 2169EDC Building Rooms One of the most annoying parts of playing through Sims 2 is waiting 8 hours for rooms to build. I couldn't stand it anymore, so I figured it out. There are 33 4-byte addresses that correspond to the time that you bought the permit to build a room in City Hall, I didn't bother figuring out how these actually equate to the time, but I'm certain this is how it works at least. It uses this and the current time with math to figure out how close to being "done" a room is. If the time from the current DS clock time and the stored time is greater than 8 hours, the value is reset to 80, which corresponds to the room being built. There are values here including rooms/locations that are not ever built, nor even part of the hotel. Even the rooms being built have values for if they are being built or not. Good luck getting Tristan to build you a desert. Government Lab (room 00) Build Progress 216B37C I won't list the rest here, but simply add 4 in hexadecimal to the address to get the address for the next room in the room list or view the game's memory with an emulator like DeSmuMe or No$GBA in that area to see the rest of them. If you set one of these room being built values to an amount that would cause the math to work out that it's been 8 or more hours since you built the room at City Hall, the value resets to 80, and the room has completed building. When this happens there are some binary flags that control what entrances/doors are active or open throughout the game. If a bit is set to 0 then it's not open, if it's set to 1, then it is open. When going to these entrances in-game, how it determines what room to load depends on the values in the build progress bytes above. If the value is 80 at the build progress byte, the entrance loads the real room, if it's not, it will load Room Being Built 1 or 2 depending on it's value. The values in room list below are grouped in the same order the binary bits are for these flags, but it's more difficult to modify this in specific without many conditionals due to them being raw binary bits that each control a different thing. This is a common problem I ran into making codes for this game actually. Pockets/Inventory and Items Pockets in Sims 2 work in a strange way, that can even lead to game-breaking bugs in the cases of some objects, such as Alien Autopsy, infamously. Essentially, you have 6 slot addresses, each 2-bytes in length, filled with the IDs of the items in your pockets. See the item list for a list of possible IDs. You also have a single address, 4-byte in length, that determines how many of the 6 total slots in your pockets are "active" (Meaning, from left to right, top to bottom, which of the 6 slots are displaying something at all). A consequence of this system is that when a slot is "emptied" while in the last slot that is active, when deleting the item, the ID slot remains unchanged. For some objects, it fails to take this into account when reading your pockets, such as the alien autopsy minigame object, which will count aliens that are in inactive slots. A result of this is that the game will erase your items until none are left (setting count to 0) and if you play any more than that, it will underflow the address's value to FF, and this causes your pockets to crash upon opening. If you save like this, you're in some pretty hot water with your save file. I'd imagine many children lost their save files to this. A somewhat simple fix for this is to make a code that writes empty slots to something else, and doesn't allow the pockets value to go above 6. Number of Active Pocket Slots 21690C0 Pocket Slot 1 2166F8C Pocket Slot 2 2166F8E Pocket Slot 3 2166F90 Pocket Slot 4 2166F92 Pocket Slot 5 2166F94 Pocket Slot 6 2166F96 Hotel Room Layouts The 6 user customizable hotel room layouts are contained in 6 arrays of data. IDs are the same as the IDs in the pockets which there's a list of below, which means you know what to look for. Locations in the room is nearby in memory too, and all the rooms are nearby to one another in memory to one another as expected. Manager's Suite Objects Array 216B235 While I only bothered finding the Manager's Suite's but there are arrays in memory nearby that are similar, I might update this post later with more details on how this works if I bother to figure it out. The array contains 14 object slots, each with multiple bytes to control their position, orientation, and what object it is. Metal Detector Charge Full Disclosure, I had a hard time figuring this out and I ended up finding a lofty workaround to make a cheat for it. Metal Detector Charge 216B140 The address is what controls the how charged the Metal Detector is. Its maximum value is 00100000, which means it is fully charged- However, writing to this value appears to not actually work when you are actually using the Metal Detector in game, and I haven't been able to figure out why very easily. There's a similar issue when working with the Sanity meter during social interaction mini-games as well. I'm sure if I spent a good hour or so I could sort both of these issues out but I decided to do something else. Useful Metal Detector Graphics Byte 213A168 I found a bit that changes from 00000001 when the metal detector is open, and to 00000000 when it is not. This is an address in the graphics area of memory, but it serves it's purpose well in making a conditional for my AR code, so there it is. Aspirations and Sanity The game handles the Sanity meter and Aspiration levels in an odd fashion, but I think I've found everything relevant to it. Aspiration 2166FCC Aspiration Level 2166FD0 Aspiration Level Progress 2166FD4 Level 0 Full = 06 Level 1 Full = 12 Level 2 Full = 1E Level 3 Full = 00 Sanity Bar Color 21690D0 Total Sanity Bar Size 21690CC Current Sanity Amount 21690C8 Player Position My friend yoyoyoshio thought a Moonjump code would be a fun idea. My initial thought was why? but I quickly decided that I'd give it a go anyway. Like Keelhaulin' this seems to be pointer stuff. Player Relevant Data Pointer 213A0AC Z-Axis Player Position Offset 4''' I didn't bother to record anything else here but there's plenty of fun stuff here you can mess with, like the scale of the player and various other things. If you want to mess with that by all means. Player Sim Needs In the Sims 2, the player's sim has needs that seem to appear at random every so often above your head, accompanied by an animation. Needs in this game do not work quite like needs in other Sims games, either. So, I'm only about 80% confident in my understanding of this but it seems that, essentially, there are 5 4-byte counter addresses that tick upwards at a fixed pace. One address for each need. There's also a counter address that ticks downwards. When this downward counter hits 0, there is a chance of one of your needs to manifest if one of the 5 upward counters is above a certain level. When a need manifests, a nearby address for this need goes from 0 to 1 while the animation plays, and then 2. Next time this need manifests, the 2 will become 3 while the animation plays, and then become 4. 3 and 4 will require you to actually fulfill the need. At this point, another nearby value is set to define the currently active need to be fulfilled. When this happens the need that you require to be fulfilled ceases to count up anymore until it is fulfilled, as your sanity begins draining instead. Whenever you fulfill a need or interact with an essential object, the need the object is associated with is reset to 0, and so is the nearby value used to determine if just an animation will play or if a need will require fulfillment. If multiple needs are at 2 when the downward counter hits 0 and resets back to 7FF, the need that will manifest will be the one with the highest counter. Playing around here I also found an address that when changed to 0, causes all the needs counters to stop, but I'm unsure if this is a permanent solution, I believe it is not. Here are all the relevant addresses. Drink Upward Counter '''21690D8 Drink Requirement State 21690E0 Food Upward Counter 21690E4 Food Requirement State 21690EC Toilet Upward Counter 21690F0 Toilet Requirement State 21690F8 Shower Upward Counter 21690FC Shower Requirement State 2169104 Bed Upward Counter 2169108 Bed Requirement State 2169110 Needs Downward Counter 2169114 Counts down from 7FF to 0, and resets back to 7FF and repeats. Active Required Need to Fulfill 2169118 FFFFFFFF = None 0 = Drink 1 = Food 2 = Toilet 3 = Shower 4 = Bed License Plate Flags The game stores which of the 24 plates you have and have not collected in raw binary flags. This is the address. License Plate Flags 2166F84 When you collect a license plate, the first 3 bytes of this address change to reflect what plates you've collected and what ones you haven't in raw binary. For documentation purposes here is what bits correspond to what bytes. 9 12AM Government Lab 10 11PM The Vault 11 10PM Asian Emporium 12 9PM Secret Warehouse | 13 8PM Sax Lounge 14 7PM Saloon Rooms 15 6PM Rat Cave 16 3PM Modern Guest Room 17 2PM Lion Lounge 18 1PM Jungle Guest Room 19 12PM Spa & Gym 20 11AM Reactor Room | 21 5PM Penthouse 22 10AM Freezer 23 9AM Desert 24 8AM Deluxe Guest Room 25 7AM Bovine Shrine 26 6AM City Hall 27 5AM Town Square 28 4AM Snake-Eyes Casino | 29 3AM Basement 30 2AM Atrium 31 1AM Art Gallery 32 4PM Sun Deck As I mentioned before working with binary flags in Action Replay codes is really annoying without making a zillion conditionals. One unfortunate annoying thing is that these bytes sadly do not actually control the unlocks for collecting the license plates, so manually setting this will not also unlock the music mixer tracks. Various Game Flags The game seems to have a lot of flags for unlockables, and what scenes you have viewed. I did figure some of them out, but I couldn't be arsed to totally figure this out down to the bits. But here are some relevant addresses anyway. Music Mixer Tracks 2166F65 Unlockable Clothes 2166F66 Unlockable Credits Theme & Moogoo Monkey 216B77E Unlockable Music Tracks for Radios 216B781 Flags for the first time you've entered a room 216B77F 216B780 Flag for if you've received the 100% letter yet 216B782 NPC Sims: Profiles, Emotions, Behavior States & More Now, there is a LOT to this, and I made a somewhat well-organized document on it for myself, but it's also not really in line with how I've laid out this document so far, so I will link it on Pastebin. Basically, there's a ton of addresses for what "State" the character is in right now, what their mood is, if they are in the profiles menu, if their secret has been unlocked, how much they like you, what portrait they use in the profiles menu, though that last one goes unused. See this page on Pastebin for the complete list of addresses and some other minor notes. Some minor things of note here: You can make an unused version of Burple the alien spawn, he has a profile and secret, and Emperor Xizzle also has a secret. Other Misc Useful Addresses This is just a collection of other addresses that may be of considerable use in some cases. Player Name (8 Bytes) 2166FB7 Run State 21690BC Simoleans 2169EC4 Fuel Rods in Pockets 2166F88 License Plates in Pockets 2166F89 Strange Gourds in Pockets 2166F8A Alien Ship Parts in Pockets 2166F8B Owed Bills 216B150 Brochures in Brochure Rack in Hotel Lobby 216B421 Fuel Rods in Furnace in the Reactor Room 216B424 Strange Gourds in Egyptian Statue in Bovine Shrine 216B42C Social Interaction Easy Mode 21690A4 21690A5 21690A6 21690A7 21690A8 Super Drencher Water 2166F7C Super Drencher Pressure 2166F80 Room Value List This is a list of values (in decimal) for what value means what location with regard to various sections above. This also maps out the order of the bits in various locations that deal in binary game flags. List of values: 0 = Government Lab * 1 = Art Gallery * 2 = Atrium 3 = Basement 4 = Casino ** 5 = Town Square 6 = City Hall 7 = Bovine Shrine *** 8 = Deluxe Guest Room * 9 = Desert 10 = Freezer 11 = Reactor Room 12 = Spa & Gym * 13 = Hotel Lobby 14 = Strangetown Jail (frequently loads you in a cell lol) 15 = Jungle Guest Room * 16 = Lion Lounge * 17 = Manager's Suite 18 = Modern Guest Room * 19 = Sun Deck 20 = Penthouse 21 = Rat Cave * 22 = Room Being Built 1 23 = Room Being Built 2 24 = Saloon 25 = Saloon Back Rooms 26 = Sax Lounge * 27 = 2nd Floor Lobby 28 = Secret Warehouse * 29 = Small Guest Room 30 = Store 31 = Asian Emporium * 32 = The Vault * * = Needs to be built with an 8 hour room build cycle ** = Needs to be built but doesn't go through a room build cycle *** = Needs to be build with an 8 hour room build cycle and has another really important flag somewhere. Item Value List The item list here applies to various sections above. The values are notated in endian swapped hexadecimal. This list is exhaustive and long and includes various unused items, test items, and items that are not pocketable. Many of these, if forced to spawn in a room, will crash if you attempt to open the room layout editor or, if placed in your pockets with memory editing, will cause the game to crash when you attempt to view the item. Because the list is so long, and because I can't be arsed to reformat it for Wikia, here is a Pastebin link. Category:Blog posts